"use strict";
cc._RF.push(module, '1f934ATQ11O/Z8lOuv86WQc', 'DragonBtn');
// scripts/Game/Obj/DragonBtn.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameConfig_1 = require("../../engines/configs/gameConfig");
var gameEngine_1 = require("../../engines/gameEngine");
var gameMode_json_1 = require("../../engines/managers/gameContent/gameMode_json");
var userInterface_1 = require("../../engines/services/userContent/userInterface");
var Const_1 = require("../Const");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.m_mode = gameMode_json_1.GAME_MODE.CALLDRAGON;
        _this.AdProgress = null;
        _this.AdIcon = null;
        return _this;
    }
    NewClass.prototype.onLoad = function () {
        this.RefreshInfo();
    };
    NewClass.prototype.OnEnterBtn = function () {
        var _this = this;
        gameEngine_1.managers().soundMgr.playSound("mainSound/anNiu");
        var mode = gameMode_json_1.GAME_MODE.CALLDRAGON;
        if (gameEngine_1.services().userSrv.getPower() - gameConfig_1.default.MODE_POWER[mode] < 0) {
            gameEngine_1.modules().uiControlModule.showUserPropGet(userInterface_1.REWARD_TYPE.POWER, gameConfig_1.default.ADD_ONCE_POWER);
            return;
        }
        // console.log("包名");
        var completeFun = function () {
            gameEngine_1.default.getManagers().gameMgr.selectMode(gameMode_json_1.GAME_MODE.CALLDRAGON);
        };
        if (!gameEngine_1.services().userSrv.getModeUnlocked(this.m_mode)) {
            gameEngine_1.services().miniGameSrv.getAppApiInstance().loadAndShowVideoAd(function () {
                gameEngine_1.services().userSrv.addModeAdCount(_this.m_mode);
            }, function (e) {
                console.error(e);
            }, function () {
                if (gameEngine_1.services().userSrv.getModeAdCount(_this.m_mode) >= gameConfig_1.default.MODE_VIDEO_COUNT[_this.m_mode]) {
                    gameEngine_1.services().userSrv.UnlockMode(_this.m_mode);
                    completeFun();
                }
                _this.RefreshInfo();
            }, "\u770B\u5E7F\u544A\u89E3\u9501" + Const_1.MODE_NAME_MAP[this.m_mode]);
            return;
        }
        completeFun();
    };
    NewClass.prototype.RefreshInfo = function () {
        // console.log("刷新模式按钮",this.m_mode,services().userSrv.getModeAdCount(this.m_mode));
        this.AdProgress.node.active = !gameEngine_1.services().userSrv.getModeUnlocked(this.m_mode);
        this.AdProgress.string = gameEngine_1.services().userSrv.getModeAdCount(this.m_mode) + ":" + gameConfig_1.default.MODE_VIDEO_COUNT[this.m_mode];
        this.AdIcon.active = !gameEngine_1.services().userSrv.getModeUnlocked(this.m_mode);
        // if(this.levelProgress){
        //     this.levelProgress.string = `${mainRoot.LevelSystem.GetFarLevel(this.m_mode)}:${mainRoot.LevelSystem.GetMaxLevel(this.m_mode)}`;
        // }
    };
    __decorate([
        property({ type: cc.Label, displayName: "广告进度" })
    ], NewClass.prototype, "AdProgress", void 0);
    __decorate([
        property({ type: cc.Node, displayName: "广告图标" })
    ], NewClass.prototype, "AdIcon", void 0);
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;

cc._RF.pop();